package com.localjoycommunity.cpdj.common.interceptor.help;


import com.localjoycommunity.cpdj.project.system.domain.User;

/**
 * @Function:
 * @Author: aqie
 * @Date: 2019/4/20 14:39
 */
public class UserContext {
    // 数据每个线程存一份
    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    public static void setUser(User user){
        userThreadLocal.set(user);
    }

    public static User getUser(){
        return userThreadLocal.get();
    }

    public static void removeUser(){
        userThreadLocal.remove();
    }

    private static final ThreadLocal<String> token = new ThreadLocal<String>();

    public static String getToken() {
        return token.get();
    }

    public static void setToken(String tokenStr) {
        token.set(tokenStr);
    }


    public static void removeToken(){
        token.remove();
    }
}
